﻿using System;
using System.Text;

namespace SwissTransTracker
{
    /// <summary>
    ///     See transport.opendata.ch
    /// </summary>
    public class TransportStop
    {
        /// <summary>
        ///     A location object showing this line's stop at the requested station.
        /// </summary>
        public Checkpoint Stop { get; set; }

        /// <summary>
        ///     The name of the connection
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        ///     The type of connection this is
        /// </summary>
        public string Category { get; set; }

        /// <summary>
        ///     The number of the connection's line, e.g. Bus line 2
        /// </summary>
        public string Number { get; set; }

        /// <summary>
        ///     The operator of the connection's line
        /// </summary>
        public string Operator { get; set; }

        /// <summary>
        ///     The final destination of this line
        /// </summary>
        public string To { get; set; }

        public override string ToString()
        {
            var sb = new StringBuilder();
            if (this.Stop != null)
                sb.AppendFormat("Stop: {0}\t{1}", Environment.NewLine,
                          this.Stop.ToString().Replace(Environment.NewLine, Environment.NewLine + '\t'));
            if (this.Name != null) sb.AppendFormat("Name: {0}{1}", this.Name, Environment.NewLine);
            if (this.Category != null) sb.AppendFormat("Category: {0}{1}", this.Category, Environment.NewLine);
            if (this.Number != null) sb.AppendFormat("Number: {0}{1}", this.Number, Environment.NewLine);
            if (this.Operator != null) sb.AppendFormat("Operator: {0}{1}", this.Operator, Environment.NewLine);
            if (this.To != null)
                sb.AppendFormat("To: {0}{1}", Environment.NewLine, this.To);
            return sb.ToString();
        }
    }
}